<template>
	<el-dialog title="" visible :show-close="false" class="wrap" size="tiny">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
	    <div class="bt">添加评价老师模版</div>
        <el-form label-width="150px" class="form">
            <el-form-item label="评价模板名称">
                <el-input v-model="mc" placeholder="请输入模板名称" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="评价项目">
                <el-select v-model="lx1" clearable class="select-block">
					<el-option v-for="v in comboxlist" :label="v.cdname" :value="v.cdname" ></el-option>
		        </el-select>
		        	注：评价项目可以在系统配置中添加
		        <el-input v-model="xq1" placeholder="请输入评价内容用空格隔开" type="textarea" :rows="2" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="评价项目名称2" v-if="false">
                <el-select v-model="lx2" clearable class="select-block">
					<el-option :label="v.cdname" :value="v.cdname" v-for="v in comboxlist"></el-option>
		        </el-select>
		        <el-input v-model="xq2" placeholder="请输入评价内容用空格隔开" type="textarea" :rows="2" class="select-block"></el-input>
		        
            </el-form-item>
            <el-form-item label="评价项目名称3"  v-if="false">
                <el-select v-model="lx3" clearable class="select-block">
					<el-option :label="v.cdname" :value="v.cdname" v-for="v in comboxlist"></el-option>
		        </el-select>
		       <el-input v-model="xq3" placeholder="请输入评价内容用空格隔开" type="textarea" :rows="2" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="评价项目名称4"  v-if="false" >
                <el-select v-model="lx4" clearable class="select-block">
					<el-option :label="v.cdname" :value="v.cdname" v-for="v in comboxlist"></el-option>
		        </el-select>
		        <el-input v-model="xq4" placeholder="请输入评价内容用空格隔开" type="textarea" :rows="2" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="评价项目名称5"  v-if="false" >
                <el-select v-model="lx5" clearable class="select-block">
					<el-option :label="v.cdname" :value="v.cdname" v-for="v in comboxlist"></el-option>
		        </el-select>
		    	<el-input v-model="xq5" placeholder="请输入评价内容用空格隔开" type="textarea" :rows="2" class="select-block"></el-input>    
            </el-form-item> 
            <el-form-item label="评价老师规则描述">
                <el-input v-model="pjgz" placeholder="请输入本次评价老师的规则" type="textarea" :rows="2" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input v-model="note" placeholder="请输入备注" type="textarea" :rows="2" class="select-block"></el-input>
            </el-form-item>
        </el-form>
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
    </el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data () {
			return {
					 mc:'',
					 lx1:'',
					 xq1:'',
					 lx2:'',
					 xq2:'',
					 lx3:'',
					 xq3:'',
					 lx4:'',
					 xq4:'',
					 lx5:'',
					 xq5:'',
					 note:'',
					 pjgz:'',
					 comboxlist:[],
			}
		},
		created () {
			this.getcomboxlist();
		},
		methods: {
			submit () {
                this.$store.state.loading = true;
				if (!this.mc) {
					this.$message.warning('请填写模板名称');
                    this.$store.state.loading = false;
					return;
				}else if(!this.lx1){
					this.$message.warning('请选择评价项目名称');
                    	this.$store.state.loading = false;
					return;
				}else if(!this.pjgz){
					this.$message.warning('请填写老师评价规则');
                    	this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                        mc: this.mc,
                        lx1: this.lx1,
                        lx2: this.lx2,
                        lx3: this.lx3,
                        lx4: this.lx4,
                        lx5: this.lx5,
                        xq1: this.xq1,
                        xq2: this.xq2,
                        xq3: this.xq3,
                        xq4: this.xq4,
                        xq5: this.xq5,
                        note:this.note,
					    pjgz:this.pjgz,
                        xxid:logininfo.xxid,
				        yhid:logininfo.id,
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xspjlsmb/insert',  params2 )
                 .then(res => {
                    if (res.data.code == 1) {
                    	this.$emit('close',{type:'add',cancel:false});
                        this.$store.state.loading = false;
                    }else{
 						this.$message.warning(res.data.msg);
                    	this.$store.state.loading = false;
                    }
                 }).catch(res => {
 					    this.$message.warning("服务器异常");
                	    this.$store.state.loading = false;
				})
            },
             getcomboxlist(){ 
					var logininfo = JSON.parse(localStorage.logininfo) ;
					var params3 = qs.stringify({ 
						xxid:logininfo.xxid,
						yhid:logininfo.id,
						pcd:'c004',
					});
					this.searchLoading = true;
					this.axios.post(this.$store.state.api + 'xxcode/getlist',params3)
					.then( res => { 
						console.log(res,'wwwwwwwwwwwwwwwww')
							this.comboxlist=res.data.data.list; 
					}).catch( res => {
							this.searchLoading = false;
					})
			},
            cancel () {
                this.$emit('close',{type:'add',cancel:true})
            },
		}
	}
</script>

<style lang="less" scoped>
    .wrap {
        text-align: center;
    }
    .form {
        // width: 300px;
        text-align: left;
    }
    .bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
    .select-block {
        display: block;
    }
    .submit {
        width: 120px;
    }
    .el-form-item {
    margin-bottom: 10px;
}
</style>
